<template>
  <div>
    <el-card class="box-card card-toubu">
      <div class="text item">
        <i class="el-icon-s-unfold"></i>
        <span>批量发货</span>
      </div>
    </el-card>
    <!-- 表格 -->
    <el-table border :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="订单编号" width="180"></el-table-column>
      <el-table-column prop="receiverContact" label="收货人" width="160"></el-table-column>
      <el-table-column prop="receiverMobile" label="手机号码" width="180"></el-table-column>
      <el-table-column prop="postFee" label="邮政编码" width="160"></el-table-column>
      <el-table-column prop="receiverAddress" label="收货地址" width="360"></el-table-column>
      <el-table-column label="配送方式" width="180">
        <template slot-scope="scope">
          <el-select v-model="scope.row.shippingName" :clearable="true" placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="物流单号" width="180">
        <template slot-scope="scope">
          <el-input placeholder="请输入物流编号" v-model="scope.row.shippingCode"></el-input>
        </template>
      </el-table-column>
    </el-table>
    <div class="anniu">
      <el-button @click="$router.go(-1)">取消</el-button>
      <el-button type="primary" @click="conmit()">确定</el-button>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      tableData: [],
      ids: "",
      options: [
        {
          value: "顺丰快递",
          label: "顺丰快递"
        },
        {
          value: "邮政快递",
          label: "邮政快递"
        },
        {
          value: "圆通快递",
          label: "圆通快递"
        },
        {
          value: "中通快递",
          label: "中通快递"
        }
      ]
    };
  },
  created () {
    // 取到路由带过来的参数
    this.ids = this.$route.query.ids;
    this.getList();
  },
  methods: {
    async getList () {
      const { data: res } = await this.$http.get(
        `vi/order/order/queryByIds/${this.ids}`
      );
      this.tableData = res.data.tbOrders;
    },
    async conmit () {
      const { data: res } = await this.$http.post(
        "vi/order/order/batchSend",
        this.tableData
      );
      console.log(res.data);
    }
  }
};
</script>
<style scoped>
.anniu {
  margin-top: 20px;
}
</style>
